import unittest
# 导入数据驱动模块
import ddt

# 测试类前加装饰器@ddt.ddt
@ddt.ddt
class DemoTestCase(unittest.TestCase):
    # 测试数据, 是多个字典的列表
    data_list = [
        {'username': 'user1', 'password': '123456'},
        {'username': 'user2', 'password': '123456'}
    ]

    def setUp(self) -> None:
        print('测试开始')

    def tearDown(self) -> None:
        print('测试结束')

    # 测试用例前加@ddt.data()
    @ddt.data(*data_list)
    def test_login(self, data):
        print(data)


if __name__ == '__main__':
    unittest.main(verbosity=2)
